/**
 入驻小区
 **/
(function (vc) {
    var DEFAULT_PAGE = 1;
    var DEFAULT_ROWS = 10;
    vc.extends({
        data: {
            aStaffDetailRepairInfo: {
                ownerRepairs: [],
                staffId: '',
                undoOrder: 'undo'
            }
        },
        _initMethod: function () {
        },
        _initEvent: function () {
            vc.on('aStaffDetailRepair', 'switch', function (_data) {
                $that.aStaffDetailRepairInfo.staffId = _data.staffId;
                $that._loadAStaffDetailRepairData(DEFAULT_PAGE, DEFAULT_ROWS)
            });
            vc.on('aStaffDetailRepair', 'paginationPlus', 'page_event',
                function (_currentPage) {
                    $that._loadAStaffDetailRepairData(_currentPage, DEFAULT_ROWS);
                });
            vc.on('aStaffDetailRepair', 'notify', function (_data) {
                $that._loadAStaffDetailRepairData(DEFAULT_PAGE, DEFAULT_ROWS);
            })
        },
        methods: {
            _loadAStaffDetailRepairData: function (_page, _row) {
                let param = {
                    params: {
                        staffId: $that.aStaffDetailRepairInfo.staffId,
                        page: _page,
                        row: _row
                    }
                };
                let _url = "/ownerRepair.listAdminUndoRepairsByStaff";
                if ($that.aStaffDetailRepairInfo.undoOrder == 'do') {
                    _url = "/ownerRepair.listAdminFinishRepairsByStaff";
                }
                //发送get请求
                vc.http.apiGet(_url,
                    param,
                    function (json) {
                        let _json = JSON.parse(json);
                        $that.aStaffDetailRepairInfo.ownerRepairs = _json.data;
                        vc.emit('aStaffDetailRepair', 'paginationPlus', 'init', {
                            total: _json.records,
                            dataCount: _json.total,
                            currentPage: _page
                        });
                    },
                    function () {
                        console.log('请求失败处理');
                    }
                );
            },
            //查询
            _qureyAStaffDetailRepair: function () {
                $that._loadAStaffDetailRepairData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _switchUndoOrder: function (_order) {
                $that.aStaffDetailRepairInfo.undoOrder = _order;
                $that._loadAStaffDetailRepairData(DEFAULT_PAGE, DEFAULT_ROWS);
            },
            _openRepairDetail: function (_repairPool) {
                vc.jumpToPage('/#/pages/work/adminRepairDetail?repairId=' + _repairPool.repairId)
            }
        }
    });
})(window.vc);